home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 February / february_2000.iso / site building / GoLive 4.0 Tryout / data1.cab / Apps / Modules / JScripts / Actions / Multimedia / Drag Floating Box.action next >
Encoding:
Text File  |  1999-08-05  |  5.4 KB  |  156 lines

  1. <html>
  2.  
  3.     <head>
  4.         <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
  5.         <meta name="generator" content="Adobe GoLive 4">
  6.         <title>Drag Floating Box Action</title>
  7.     </head>
  8.  
  9.     <body bgcolor="white">
  10.         <center>
  11.             <font size="6">Drag Floating Box Action</font><font>
  12.             <hr>
  13.             </font></center>
  14.         <p><font>
  15.         <csactionclass name="Drag Floating Box" function="CSDrag" nsversion="4" ieversion="4"> </font></p>
  16.         <p><font>
  17.         <csactionparam name="layer" type="GLActionLayerParam"> </font></p>
  18.         <p><font></csactionparam>
  19.          </font></p>
  20.         <p><font></csactionclass>
  21.          </font></p>
  22.         <p>
  23.         <hr>
  24.         </p>
  25.         <p>IE Functions Script
  26.         <script language="JavaScript1.2" src="../../GlobalScripts/IE.scpt" cyberversion="N1.2"></script>
  27.         </p>
  28.         <p>Drag Action Main Script<font>
  29.         <script language="JavaScript1.2" cyberversion="N1.2"><!--
  30. var gCSIEDragObject = null;
  31. function CSSetupDrag (layerName) {
  32.     this.x = 0; this.y = 0;
  33.     if (IsIE()) {
  34.         this.canDrag=true; 
  35.         this.layerObj=document.all.tags("div")[layerName];
  36.         this.layerObj.dragObj = this;
  37.         document.ondragstart = CSIEStartDrag;
  38.         document.onmousedown = CSIEMouseDown;
  39.         document.onmouseup = CSIEStopDrag;
  40.     } else {
  41.         this.layer=CSNSStyl(layerName);this.onmousemove=null; 
  42.         this.layer.document.theLayer=this;
  43.         this.layer.document.captureEvents(Event.MOUSEDOWN);
  44.         this.layer.document.onmousedown=CSNSStartDrag; 
  45.         this.layer.document.onmouseup=CSNSStopDrag;
  46.     }
  47. }
  48. function CSNSStartDrag (ev) {
  49.     var clickInMe = false;
  50.     if (ev.target != this) {
  51.         for (var i=0;i<this.images.length;i++) {
  52.             if (this.images[i] == ev.target) { clickInMe = true; break;}
  53.             }
  54.         }
  55.     else clickInMe = true;    
  56.     if (clickInMe)
  57.         {
  58.         this.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); 
  59.         this.onmousemove=CSNSDoDrag;
  60.         this.theLayer.x= ev.pageX;
  61.         this.theLayer.y= ev.pageY;
  62.         this.routeEvent(ev);
  63.         return false;
  64.         }
  65.    this.onmousemove=null;this.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
  66.     this.routeEvent(ev);
  67.    return true; 
  68. }
  69. function CSNSStopDrag (ev) {
  70.    this.onmousemove=null;this.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);return false; 
  71. }
  72. function CSNSDoDrag (ev) {
  73.     this.theLayer.layer.moveBy(ev.pageX-this.theLayer.x, ev.pageY-this.theLayer.y); 
  74.     this.theLayer.x = ev.pageX; 
  75.     this.theLayer.y = ev.pageY;
  76.     this.routeEvent(ev);
  77. }
  78. function CSIEStartDrag () {
  79.     if(gCSIEDragObject != null && (gCSIEDragObject.tagName==event.srcElement.tagName))
  80.         event.returnValue=false;  
  81. }
  82. function CSIEStopDrag () { gCSIEDragObject=null; document.onmousemove=null; }
  83. function CSIEMouseDown () {
  84.     if(event.button==1) {
  85.         dragLayer = event.srcElement;
  86.         while (dragLayer!=null) 
  87.             {
  88.             if ((dragLayer.dragObj == null) && (dragLayer.tagName == "DIV"))
  89.                 break;
  90.             if (dragLayer.dragObj != null)
  91.                 break;
  92.             dragLayer=dragLayer.parentElement;
  93.             }
  94.             
  95.         if (dragLayer == null) return;
  96.         if (dragLayer.dragObj!=null && dragLayer.dragObj.canDrag) {
  97.             gCSIEDragObject = dragLayer;
  98.             gCSIEDragObject.dragObj.x=event.clientX;
  99.             gCSIEDragObject.dragObj.y=event.clientY;
  100.             document.onmousemove = CSIEMouseMove;
  101.         }
  102.     }
  103. }
  104. function CSIEMouseMove () {
  105.     gCSIEDragObject.dragObj.layerObj.style.pixelLeft+=(event.clientX-gCSIEDragObject.dragObj.x);
  106.     gCSIEDragObject.dragObj.layerObj.style.pixelTop+=(event.clientY-gCSIEDragObject.dragObj.y);
  107.     gCSIEDragObject.dragObj.x=event.clientX;
  108.     gCSIEDragObject.dragObj.y=event.clientY;
  109.     event.returnValue = false;
  110.     event.cancelBubble = true;
  111. }
  112. var gDragArray = new Array();
  113. function CSDrag(action) { gDragArray[gDragArray.length] = new CSSetupDrag(action[1]); }
  114. // -->
  115.         </script>
  116.         </font></p>
  117.         <p>
  118.         <hr>
  119.         </p>
  120.         <p> </p>
  121.         <p><font>
  122.         <table cool width="253" height="153" border="0" cellpadding="0" cellspacing="0" gridx="16" showgridx gridy="16" showgridy bgcolor="#eeeeee">
  123.             <tr height="1" cntrlrow>
  124.                 <td width="1" height="1"><spacer type="block" width="1" height="1"></td>
  125.                 <td width="10" height="1"><spacer type="block" width="10" height="1"></td>
  126.                 <td width="80" height="1"><spacer type="block" width="80" height="1"></td>
  127.                 <td width="160" height="1"><spacer type="block" width="160" height="1"></td>
  128.             </tr>
  129.             <tr height="2">
  130.                 <td width="1" height="2"><spacer type="block" width="1" height="2"></td>
  131.                 <td width="10" height="2"><spacer type="block" width="10" height="2"></td>
  132.                 <td width="80" height="2"><spacer type="block" width="80" height="2"></td>
  133.                 <td width="160" height="2"><spacer type="block" width="160" height="2"></td>
  134.             </tr>
  135.             <tr height="3">
  136.                 <td width="1" height="3"><spacer type="block" width="1" height="3"></td>
  137.                 <td width="10" height="3"><spacer type="block" width="10" height="3"></td>
  138.                 <td width="80" height="3"><spacer type="block" width="80" height="3"></td>
  139.                 <td width="160" height="148" colspan="1" rowspan="2" valign="top" align="left" xpos="90">
  140.                     <csactioncntrl name="layer" x="90" y="2" width="140" height="18" alignx="scale" aligny="top">
  141.                 </td>
  142.             </tr>
  143.             <tr height="145">
  144.                 <td width="1" height="145"><spacer type="block" width="1" height="145"></td>
  145.                 <td width="10" height="145"><spacer type="block" width="10" height="145"></td>
  146.                 <td width="80" height="145" colspan="1" rowspan="1" valign="top" align="left" xpos="10">
  147.                     <csactioncntrl type="StaticText" value="Floating Box" x="10" y="5" width="75" height="16" alignx="left" aligny="top">
  148.                 </td>
  149.             </tr>
  150.         </table>
  151.         </font></p>
  152.         <p> 
  153.     </body>
  154.  
  155. </html>
  156.